﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebApplication6.DAL.DataSetFenleiTableAdapters;

namespace WebApplication6.manage
{
    public partial class fenlei : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string action = Request["action"];

                if (action == "add")
                {
                    Label1.Text = "添加新商品分类";
                }
               
                else if (action == "del")
                {
                    string id = Request["id"];

                    t_fenleiTableAdapter adapter = new t_fenleiTableAdapter();

                    adapter.Delete(Convert.ToInt32(id));

                    Response.Write("<script language=javascript>alert('操作成功');window.location.href='fenleilist.aspx';</script>");

                }
                else
                {

                    throw new Exception("action错误" + action);
                }


            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            if (!IsValid)
            {

                return;
            }

            string action = Request["action"];

            if (action == "add")
            {
                t_fenleiTableAdapter adapter = new t_fenleiTableAdapter();


                adapter.Insert(mingchen.Text);

                Response.Write("<script language=javascript>alert('操作成功');window.location.href='fenleilist.aspx';</script>");
            }
            
            else
            {

                throw new Exception("action错误" + action);
            }

        }
    }
}
